package com.pl.museumguide.activities;

import java.io.File;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;



public class List extends ListActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);			
		File dir = new File(Environment.getExternalStorageDirectory()
	            + File.separator + "MuseumGuide" + File.separator + "Zabytki");
		if(!(dir.exists())) {
			dir.mkdirs();
		}
			File[] fileList = dir.listFiles();
			String[] fileNames = new String[fileList.length];
			for(int i=0;i<fileNames.length;i++){
				fileNames[i] = fileList[i].getName();
			}
			setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1 ,fileNames));
		
		
	}
	public void onListItemClick(
			ListView parent, View v, int position, long id)
			{
				Intent i = new Intent(getApplicationContext(), Wyswietl.class);
				String selection = parent.getItemAtPosition(position).toString();
				i.putExtra("nazwa",selection);
				startActivity(i);
			}
}